package com.cskaoyan.market.service.impl;

import com.cskaoyan.market.service.MemberCollectService;
import com.cskaoyan.market.db.domain.MarketCollect;
import com.cskaoyan.market.db.domain.MarketCollectExample;
import com.cskaoyan.market.db.mapper.MarketCollectMapper;
import com.cskaoyan.market.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author TangHonghao
 * @since 2023/03/20 21:24
 */
public class MemberCollectServiceImpl implements MemberCollectService {
    @Override
    public List<MarketCollect> selectMarketCollectByUserId(Integer uId) {
        SqlSession session = MyBatisUtil.getSession();
        MarketCollectMapper marketCollectMapper = session.getMapper(MarketCollectMapper.class);
        MarketCollectExample marketCollectExample = new MarketCollectExample();
        marketCollectExample.or().andUserIdEqualTo(uId);
        List<MarketCollect> marketCollects = marketCollectMapper.selectByExample(marketCollectExample);
        session.commit();
        session.close();
        return marketCollects;

    }

    @Override
    public List<MarketCollect> selectMarketCollectByValueId(Integer vId) {
        SqlSession session = MyBatisUtil.getSession();
        MarketCollectMapper marketCollectMapper = session.getMapper(MarketCollectMapper.class);
        MarketCollectExample marketCollectExample = new MarketCollectExample();
        marketCollectExample.or().andValueIdEqualTo(vId);
        List<MarketCollect> marketCollects = marketCollectMapper.selectByExample(marketCollectExample);
        session.commit();
        session.close();
        return marketCollects;
    }
}



















